<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../../resources/js-test.js"></script>
<script src="../resources/common-setrangetext.js"></script>
</head>
<body>
<script>
description("Test setRangeText() method on textareas.");

runTestsShouldPass("textarea");

element = document.createElement("textarea");
document.body.appendChild(element);
debug("\nCheck that setRangeText() on textareas doesn't affect scroll position.");
var longString = "";
for (var i = 0; i < 20; i++)
    longString += "0123456789\n";
evalAndLog("element.value = longString");
evalAndLog("element.scrollTop = 0");
evalAndLog("element.setSelectionRange(100, 110)");
evalAndLog("element.setRangeText('A', 9999, 9999, 'select')");
shouldBe("element.value", "longString+'A'");
shouldBe("element.selectionStart", "longString.length");
shouldBe("element.selectionEnd", "longString.length+1");
shouldBe("element.scrollTop", "0");

runTestsShouldPass("textarea", { dir: "rtl" });
</script>
</body>
</html>

